function * range(start, end) {
    while (start <= end) {
        yield start++;
    }
}

for (let i of range(4, 7)) {
    console.log(i)
}

// 4
// 5
// 6
// 7